#include "testApp.h"
#include "stdio.h"

//--------------------------------------------------------------
testApp::testApp(){

}

//---------------------------------------------------- ----------
void testApp::setup(){
    lijstA.push_back("stap01.wav");
    lijstA.push_back("stap02.wav");
    lijstA.push_back("stap03.wav");
    lijstA.push_back("stap04.wav");
    lijstA.push_back("stap05.wav");
    lijstA.push_back("stap06.wav");
    lijstA.push_back("stap07.wav");
    lijstA.push_back("stap08.wav");
    lijstA.push_back("stap09.wav");
    lijstA.push_back("stap10.wav");
    lijstB = lijstA;
}

//--------------------------------------------------------------
void testApp::update(){
    ofSerial mySerial;
    mySerial.setup("COM3", 9600);
    string returnValue;

    unsigned char bytes[1] = {0};
    while (bytes[0]!='\n') {
         if (mySerial.readBytes(bytes,1)>0) returnValue+=bytes[0];
    }

    returnValue.erase( 1 );
    cout << "Value: (" << returnValue << ")" << endl;

    if (returnValue == "A") {
        int getal = (int)ofRandom(0,lijstB.size());
        cout << lijstB[getal] << endl;
        sound.loadSound(lijstB.at(getal));
        sound.play();
        lijstB.erase(lijstB.begin() + getal);
        if (lijstB.size()==0) lijstB = lijstA;
    }
}

//--------------------------------------------------------------
void testApp::draw(){
}

//--------------------------------------------------------------
void testApp::keyPressed(int key){

}

//--------------------------------------------------------------
void testApp::keyReleased(int key){

}

//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){

}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void testApp::resized(int w, int h){

}

